const fs = require('fs');
const path = require('path');
function loadRoutes(filePath) {
    const files = fs.readdirSync(filePath);
    files.filter(file => {
        if(filePath !== __dirname && file === 'index.js') {
            //
        }
        return file !== 'index.js' && file !== 'db.js'
    }).forEach(file => {
        let newFilePath = path.join(filePath, file);
        if(fs.statSync(newFilePath).isDirectory()) {
            loadRoutes(newFilePath);
        } else {
            require(newFilePath);
        }
    })
}

loadRoutes(__dirname);
